/*
 * @lc app=leetcode.cn id=884 lang=javascript
 *
 * [884] 两句话中的不常见单词
 */

// @lc code=start
/**
 * @param {string} s1
 * @param {string} s2
 * @return {string[]}
 */
var uncommonFromSentences = function (s1, s2) {
  const A = {}, B = {};
  s1.split(' ').forEach(item => {
    A[item] = A[item] ? A[item] + 1 : 1;
  })
  s2.split(' ').forEach(item => {
    B[item] = B[item] ? B[item] + 1 : 1;
  })
  const result = [];
  for(let word in A) {
    if(A[word] === 1 && !B[word]) {
      result.push(word);
    }
  }
  for(let word in B) {
    if(B[word] === 1 && !A[word]) {
      result.push(word);
    }
  }
  return result;
};
// @lc code=end

